package com.jun.admin.core.model.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author yuejun.li
 * @date 2024/6/11 17:20:02
 */
@Slf4j
@Aspect
@Component
public class SelectLogAspect {

    //切点
    @Pointcut("@annotation(com.jun.admin.core.model.aspect.SelectLog)")
    public void selectLog(){

    }


    @Around("selectLog()")
    public void doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        Signature signature = proceedingJoinPoint.getSignature();
        long startTime = System.currentTimeMillis();
        proceedingJoinPoint.proceed();
        long endTime = System.currentTimeMillis();
        String name = signature.getName();
        log.info("该"+ name +"接口总耗时总耗时：{}ms",endTime - startTime);
    }
}
